﻿using BW.MesProject.Production.Domain.Dto.Input;
using BW.MesProject.Production.Domain.Dto.Input.ProductLock;
using BW.MesProject.Production.Domain.Dto.Output.ProductLock;
using BW.MesProject.Production.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.Production.Host.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductLockController : ControllerBase
    {
        private readonly IProductLockServices _productLockServices;
        
        public ProductLockController(IProductLockServices productLockServices)
        {
            _productLockServices = productLockServices;
        }
        /// <summary>
        /// 添加产品锁定信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> CreateProductLock(ProductLockInput input)
        {
            return _productLockServices.CreateProductLock(input);
        }
        /// <summary>
        /// 获取产品锁定列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ProductLockOutput>> GetProductLocks([FromQuery]ListInput input)
        {
            return _productLockServices.GetProductLocks(input);
        }
        /// <summary>
        /// 获取产品解锁列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<ProductUnLockOutput> GetProductUnLock([FromQuery]PageInput input)
        {
            return _productLockServices.GetProductUnLock(input);
        }
        /// <summary>
        /// 产品解锁
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteProductUpLock(string code)
        {
            return _productLockServices.DeleteProductUpLock(code);
        }
    }
}
